package com.suntoon.framework.controller;

import com.suntoon.framework.annotation.SkipLogin;
import com.suntoon.framework.common.response.ResultBO;
import com.suntoon.framework.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author: LEAVES
 * @Version 1.0
 * @Date: 2021年06月25日 09时30分38秒
 * @Description:
 */
@Slf4j
@CrossOrigin
@RestController
//@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @PostMapping("/login")
    @SkipLogin
    public ResultBO login(@RequestParam("username") String username, @RequestParam("password") String password,
                          HttpServletResponse response) {
        return userService.login(username, password, response);

    }

    @GetMapping("/user/x")
    @SkipLogin
    public ResultBO x() {
        return ResultBO.success("成功，--------有跳过登录注解");

    }

    @GetMapping("/user/y")
    public ResultBO y() {
        return ResultBO.success("成功，--------无跳过登录注解");
    }

    @GetMapping("/user/z")
    @SkipLogin
    public ResultBO z(@RequestParam("z") Integer z) {
        int x = 1;
        x = x / z;
        return ResultBO.success("成功，--------参数测试 z = " + x);

    }
}
